/*******************************************************************************
Table X.do


This file uses 4 datasets created by "Code\Setup\regressionMatrix_Ls.do" and 
"Code\Setup\regressionMatrixDelta9_Ls.do". Each regression result is one column 
of the regression table X in the draft. 


Last updated:02/27/2023
*******************************************************************************/


clear
version 15
cd "C:\Plants_in_Space"
set more off
set type double
set varabbrev off
graph set window fontface "Times New Roman" 


// Column 1 (delta = 9, M = 2) We regress firm's employment on local weighted employment.
import delimited "Data\Ls9_sorting_regression_tbl1.csv"
label variable log_tot_rev "$\ln L_{(q)}$"
reghdfe log_weight_pop log_tot_rev, noabsorb vce(robust) res
outreg2 using "Tables\TableX.tex", label replace tex(fragment) nocons ///
	ctitle("\textit{$ \Delta = 9$}", "$\hspace{3.2em}\ln \bar{L}_{(q)}\hspace{3.2em}$") addtext(M, 2)

// Column 2 (delta = 9, M = 3) We regress firm's employment on local weighted employment. 
preserve
	import delimited "Data\Ls9_sorting_regression_tbl2.csv", clear
	label variable log_tot_rev "$\ln L_{(q)}$"
	reghdfe log_weight_pop log_tot_rev, noabsorb vce(robust) res
	outreg2 using "Tables\TableX.tex", label append tex(fragment) nocons ///
		ctitle("\textit{$ \Delta = 9$}", "$\hspace{3.2em}\ln \bar{L}_{(q)}\hspace{3.2em}$") addtext(M, 3)
restore 

// Column 3 (delta = 1, M = 2) We regress firm's employment on local weighted employment. 
preserve
	import delimited "Data\Ls_sorting_regression_tbl1.csv", clear
	label variable log_tot_rev "$\ln L_{(q)}$"
	reghdfe log_weight_pop log_tot_rev, noabsorb vce(robust) res
	outreg2 using "Tables\TableX.tex", label append tex(fragment) nocons ///
		ctitle("\textit{$ \Delta = 1$}", "$\hspace{3.2em}\ln \bar{L}_{(q)}\hspace{3.2em}$") addtext(M, 2)
restore 

// Column 4 (delta = 1, M = 3) We regress firm's employment on local weighted employment.
preserve
	import delimited "Data\Ls_sorting_regression_tbl2.csv", clear
	label variable log_tot_rev "$\ln L_{(q)}$"
	reghdfe log_weight_pop log_tot_rev, noabsorb vce(robust) res
	outreg2 using "Tables\TableX.tex", label append tex(fragment) nocons ///
		ctitle("\textit{$ \Delta = 1$}", "$\hspace{3.2em}\ln \bar{L}_{(q)}\hspace{3.2em}$") addtext(M, 3)
restore	








